﻿@model ShoppingCartModel
@using Nop.Web.Models.ShoppingCart;
<div class="order-summary-content">
    @Html.Widget("order_summary_content_before")
    @Html.Partial("_OrderReviewData", Model.OrderReviewData)
    @if (Model.Items.Count > 0)
    {
        if (Model.Warnings.Count > 0)
        {
        <div class="message-error">
            <ul>
                @for (int i = 0; i < Model.Warnings.Count; i++)
                {
                    <li>@Model.Warnings[i]</li>
                }
            </ul>
        </div>
        }
@*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@
        using (Html.BeginRouteForm("ShoppingCart", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
        <div class="cart-info">
            <table class="cart">
                <colgroup>
                    @if (Model.IsEditable)
                    {
                        <col width="1" />
                    }
                    @if (Model.ShowSku)
                    {
                        <col width="1" />
                    }
                    @if (Model.ShowProductImages)
                    {
                        <col width="1" />
                    }
                    <col />
                    <col width="1" />
                    <col width="1" />
                    <col width="1" />
                </colgroup>
                <thead>
                    <tr class="cart-header-row">
                        @if (Model.IsEditable)
                        {
                            <td>
                                @T("ShoppingCart.Remove")
                            </td>
                        }
                        @if (Model.ShowSku)
                        {
                            <td>
                                @T("ShoppingCart.SKU")
                            </td>
                        }
                        @if (Model.ShowProductImages)
                        {
                            <td class="image"></td>
                        }
                        <td class="name">
                            @T("ShoppingCart.Product(s)")
                        </td>
                        <td class="price">
                            @T("ShoppingCart.UnitPrice")
                        </td>
                        <td class="quantity">
                            @T("ShoppingCart.Quantity")
                        </td>
                        <td class="total">
                            @T("ShoppingCart.ItemTotal")
                        </td>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.Items)
                    {
                        <tr class="cart-item-row">
                            @if (Model.IsEditable)
                            {
                                <td class="remove-from-cart">
                                    <input type="checkbox" name="removefromcart" value="@(item.Id)" />
                                </td>
                            }
                            @if (Model.ShowSku)
                            {
                                <td class="sku nobr">
                                    @item.Sku
                                </td>
                            }
                            @if (Model.ShowProductImages)
                            {
                                <td class="product-picture">
                                    <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
                                </td>
                            }
                            <td class="product">
                                <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="View details">@item.ProductName</a>
                                @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                {
                                    <div class="attributes">
                                        @Html.Raw(item.AttributeInfo)
                                    </div>
                                }
                                @if (!String.IsNullOrEmpty(item.RecurringInfo))
                                {
                                    <div class="recurring-info">
                                        @Html.Raw(item.RecurringInfo)
                                    </div>
                                }
                                @if (item.Warnings.Count > 0)
                                {
                                    <div class="message-error">
                                        <ul>
                                            @for (int i = 0; i < item.Warnings.Count; i++)
                                            {
                                                <li>@item.Warnings[i]</li>
                                            }
                                        </ul>
                                    </div>
                                }
                            </td>
                            <td class="unit-price nobr">
                                <span class="product-unit-price">@item.UnitPrice</span>
                            </td>
                            <td class="qty nobr">
                                @if (Model.IsEditable)
                                {
                                    if (item.AllowedQuantities.Count > 0)
                                    {
                                    <select name="itemquantity@(item.Id)" class="qty-dropdown">
                                        @foreach (var qty in item.AllowedQuantities)
                                        {
                                            <option selected="@qty.Selected" value="@qty.Value">@qty.Value</option>
                                        }
                                    </select>
                                    }
                                    else
                                    {
                                    <input name="itemquantity@(item.Id)" type="text" value="@(item.Quantity)" class="qty-input" />
                                    }

                                }
                                else
                                {
                                    <span>@item.Quantity</span>
                                }
                            </td>
                            <td class="subtotal nobr end">
                                <span class="product-subtotal">@item.SubTotal</span>
                                @if (!String.IsNullOrEmpty(item.Discount))
                                {
                                    <div class="discount">
                                        @T("ShoppingCart.ItemYouSave"): @item.Discount
                                    </div>
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
                    if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
                    {
        <div class="selected-checkout-attributes">
            @Html.Raw(Model.CheckoutAttributeInfo)
        </div>
                    }
        <div class="buttons">
            @if (Model.IsEditable)
            {
                <div class="common-buttons">
                    <input type="submit" name="updatecart" value="@T("ShoppingCart.UpdateCart")" class="button" />
                    <input type="submit" name="continueshopping" value="@T("ShoppingCart.ContinueShopping")" class="button" />
                    <input type="submit" name="startcheckout" value="startcheckout" id="startcheckout"
                        style="display: none;" />
                </div>
                @Html.Partial("_CheckoutAttributes", Model.CheckoutAttributes, new ViewDataDictionary())
            }
        </div>
        <div class="cart-footer">
            @Html.Widget("order_summary_cart_footer")
            @if (Model.IsEditable)
            {
                if (!String.IsNullOrEmpty(Model.MinOrderSubtotalWarning))
                {
                <div>
                    <div class="min-amount-warning">
                        @Model.MinOrderSubtotalWarning
                    </div>
                </div>
                }
            }
            <div class="cart-collaterals">
                @if (Model.IsEditable)
                {
                    <div class="deals">
                        @Html.Partial("_DiscountBox", Model.DiscountBox)
                        @Html.Partial("_GiftCardBox", Model.GiftCardBox)
                        @Html.Widget("order_summary_content_deals")
                    </div>
                    @Html.Partial("EstimateShipping", Model.EstimateShipping)
                }
            </div>
            <div class="buttons">
                @Html.Action("OrderTotals", "ShoppingCart", new { isEditable = Model.IsEditable })
                @if (Model.IsEditable)
                {
                    if (Model.TermsOfServiceEnabled)
                    {
                    <div id="terms-of-service-warning-box" title="@T("Checkout.TermsOfService")" style="display:none;">
                        <p>@T("Checkout.TermsOfService.PleaseAccept")</p>
                    </div>
                    <div class="terms-of-service">
                        <input id="termsofservice" type="checkbox" name="termsofservice" />
                        @T("Checkout.TermsOfService.IAccept")
                        @*uncomment below to how simple pop-up*@ @*<span class="read" onclick="javascript:OpenWindow('@Url.RouteUrl("TopicPopup", new { SystemName = "conditionsofUse" })', 450, 500, true)">@T("Checkout.TermsOfService.Read")</span>*@
                        @*use fancybox to how nice pop-up*@
                        @{
                        Html.AddScriptParts("~/Scripts/jquery.fancybox-1.3.4.pack.js");
                        Html.AddCssFileParts("~/Content/fancybox/jquery.fancybox-1.3.4.css");
                        }
                        <a class="read" href='@Url.RouteUrl("TopicPopup", new { SystemName = "conditionsofUse" })'>@T("Checkout.TermsOfService.Read")</a>
                        <script type="text/javascript">
                            $(".terms-of-service .read").fancybox({
                                'speedIn': 600,
                                'speedOut': 200,
                                'width': 450,
                                'height': 500,
                                'type': 'iframe',
                                'centerOnScroll': true
                            });
                        </script>
                    </div>
                    }
                }
                <div>
                    @if (String.IsNullOrEmpty(Model.MinOrderSubtotalWarning))
                    {
                        <script type="text/javascript">
                            $(document).ready(function () {
                                $('#checkout').click(function () {
                                    //terms of services
                                    var termOfServiceOk = true;
                                @if (Model.TermsOfServiceEnabled)
                                {
                                        <text>
                                if (!$('#termsofservice').is(':checked')) {
                                    $("#terms-of-service-warning-box").dialog();
                                    termOfServiceOk = false;
                                }
                                else {
                                    termOfServiceOk = true;
                                }
                                        </text>
                                }
                                if (termOfServiceOk) {
                                    $('#startcheckout').trigger("click");
                                }
                            });
                        });
                        </script>
                        <div class="right" style="margin-top:10px">
                            <input type="button" id="checkout" name="checkout" class="button" value="@T("Checkout.Button")"></input>
                        </div>
                        <div class="center">
                        </div>
                    }
                </div>
            </div>

            @if (Model.IsEditable)
            {
                @Html.Action("CrossSellProducts", "Catalog")
            }
        </div>
        }
        if (Model.IsEditable)
        {
        <div class="addon-buttons">
            @*Payment method buttons (e.g. GoogleCheckoutButton, Paypal Express)*@
            @Html.Partial("_ButtonPaymentMethod", Model)
        </div>
        }
    }
    else
    {
        @T("ShoppingCart.CartIsEmpty")
    }
    @Html.Widget("order_summary_content_after")
</div>
